

if ( SERVER ) then

	AddCSLuaFile( "shared.lua" )
	
end

if ( CLIENT ) then

	SWEP.PrintName			= "AUG"			
	SWEP.Author				= "Counter-Strike"
	SWEP.Slot				= 2
	SWEP.SlotPos			= 0
	SWEP.IconLetter			= "e"
	
	killicon.AddFont( "weapon_aug", "CSKillIcons", SWEP.IconLetter, Color( 255, 80, 0, 255 ) )
	
end

SWEP.HoldType			= "ar2"
SWEP.Base				= "weapon_cs_base2_snipe_ds"

SWEP.Spawnable			= true
SWEP.AdminSpawnable		= true

SWEP.ViewModel 			= "models/weapons/v_rif_aug.mdl"
SWEP.WorldModel 		= "models/weapons/w_rif_aug.mdl"

SWEP.Weight				= 5
SWEP.AutoSwitchTo		= false
SWEP.AutoSwitchFrom		= false
SWEP.ShouldDrawCrosshair	= true

SWEP.Primary.Sound			= Sound( "Weapon_Aug.Single" )
SWEP.Primary.Recoil			= 1.3
SWEP.Primary.Damage			= 12
SWEP.Primary.NumShots		= 1
SWEP.Primary.Cone			= 0.0155
SWEP.Primary.ClipSize		= 30
SWEP.Primary.Delay			= 0.082
SWEP.Primary.DefaultClip	= 120
SWEP.Primary.Automatic		= true
SWEP.Primary.Ammo			= "smg1"

SWEP.Secondary.Automatic	= false
SWEP.Secondary.Ammo			= "none"

function SWEP:SecondaryAttack()
	self.Weapon:SetNextSecondaryFire( CurTime() + self.Secondary.Delay )
	self.Weapon:SetNextPrimaryFire( CurTime() + self.Secondary.Delay )
	self.NextReload = CurTime() + self.Secondary.Delay

	if self.Weapon:GetNetworkedBool( "Zoomed", false ) then
		self.Weapon:SetNetworkedBool( "Zoomed", false )
		self.Weapon:SetNetworkedInt( "Zoom", 1 )
		self.Primary.Cone = 0.0125
		self.Primary.Recoil = 0.55
	else
		self.Weapon:SetNetworkedBool( "Zoomed", true )
		self.Weapon:SetNetworkedInt( "Zoom", 1.5 )
		self.Primary.Cone = 0.0075
		self.Primary.Recoil = 0.35
	end
end

function SWEP:Think()
	if self.NeedToReload then
		self:Reload()
	end
	
	if self.Weapon:Clip1() < 1 and !self.Owner:KeyDown( IN_ATTACK ) and !self.AutoReloading then
		self:Reload()
		self.AutoReloading = true
		return
	end

	if self.Weapon:Clip1() > 0 then
		self.AutoReloading = false
	end
	if self.Weapon:GetNetworkedBool( "Zoomed", false ) then
		self.Primary.Delay = 0.16
	else
		self.Primary.Delay = 0.082
	end

	if CLIENT and self.Weapon:GetNetworkedBool( "Zoomed", false ) then
		self.MouseSensitivity = ( self.Owner:GetFOV() / 70 ) / 3 -- scale sensitivity
	else
		self.MouseSensitivity = 1
	end
end

function SWEP:Reload()
	if self.Owner:KeyDown( IN_ATTACK ) then
		self.NeedToReload = true
		return
	end
	self.NeedToReload = false
	self.Weapon:SetNetworkedBool( "Zoomed", false )
	self.Weapon:SetNetworkedInt( "Zoom", 1 )
	self.Weapon:DefaultReload( ACT_VM_RELOAD)
end